<template>
  <div class="toast" v-show="isShow">
    <div>{{ message }}</div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      isShow: false,
      message: "我是提示",
      flag: false,
    };
  },
  methods: {
    show(message, time = 2000) {
      this.isShow = true;
      this.message = message;
      setTimeout(() => {
        this.isShow = false;
        this.message = "";
      }, time);
    },
  },
};
</script>

<style scoped lang='less'>
.toast {
  position: fixed;
  top: 50%;
  left: 50%;
  padding: 8px 20px;
  transform: translate(-50%, -50%);
  background-color: rgba(0, 0, 0, 0.7);
  color: #fff;
  z-index: 44;
}
</style>